Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
Why do I have the error of "Undefined variable: req"?

I want to display a map of the search. But I keep getting "undefined variable: req" notification. What should I change from my following code:

var jQuery_1_8_2 = jQuery.noConflict();
    $(function () {
        var array = JSON.parse('{!! !empty($total_search_query) ? json_encode($total_search_query) : "[]" !!}');
        console.log(array);
        $('#map2').vectorMap({
            map: 'indonesia-adm1_merc',
            backgroundColor: '#ADF3F0',
            regionStyle: {
                initial: {
                    fill: '#FFFFFF'
                },
                hover: {
                    fill: '#175083'
                }
            },
            zoomButtons: false,
            zoomOnScroll: false,
            zoomOnClick: false,
            zoomMax: 1,
            normalizeFunction: 'polynomial',
            onRegionClick: function (event, code) {
                var url = '{{ route("search", ["q" => $req->input("q"), "province" => ":id"]) }}';
                url = url.replace("%3Aid", code.toLowerCase());
                window.location.href = url;
            },
            onRegionTipShow: function (event, label, code) {
                var map = $('#map2').vectorMap('get', 'mapObject');
                var regionName = map.getRegionName(code);
                var a = array.find(a => a.name === myTrim(regionName))['count'];
                
                label.html('<div class="map-tooltip"><h4 class="header">' + regionName + '</h4><p class="description">Total: ' + a + '</p></div>');
            }
        });
    }(jQuery_1_8_2));
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem is with the $req->input("q") part that you can determine via looking at the error message which complains about $req not being defined. The reason is that in your Laravel code at some place you have stored the result of request() into a variable called $req, which does not exist in this context. This is the view part, while you have probably parsed the result of request() in your controller. As a result you will need

request()->input("q")

instead.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!